<% content_for :page_head do %>
  <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.min.js"></script> 
  <link rel="stylesheet" href="http://tablesorter.com/themes/blue/style.css" />
  <script type="text/javascript" src="http://autobahn.tablesorter.com/jquery.tablesorter.min.js"></script>
  <script type="text/javascript" src="http://tablesorter.com/addons/pager/jquery.tablesorter.pager.js"></script>
<% end %>
<% content_for :ujs do %>
  $.noConflict();
  (function($){
    $(document).ready(function(){
      $("#wiki_list_check_box_all").click(function(){
        if($(this).attr('checked') == 'checked')
        {
          jQuery.each($('[name="page_id[]"]'), function() {
            $(this).attr('checked', 'checked');
          });
        }
        else
        {
          jQuery.each($('[name="page_id[]"]'), function() {
            $(this).removeAttr('checked');
          });
        }
      });

      $(":submit").click(function(){
        if($(':checkbox[name="page_id[]"]:checked').length == 0){
        alert('<%= t('No selected items.', :scope => [:wiki, :message]) %>');
          return false;
        }
      });
  
      $("table") 
        .tablesorter({widthFixed: true, widgets: ['zebra'], headers:{0:{sorter:false}}})
        .tablesorterPager({container: $("#pager"), size:10, positionFixed:false}); 
    });
  })(jQuery);
<% end %>

<h2><%= t('Pages List', :scope => :wiki) %></h2>

<%= render :partial => "functions"%>
<hr/>

<%= form_tag :action => 'list' do %>
  <% if @wiki_permit -%>
    <%= submit_tag "#{t('Export', :scope => :wiki)} Wiki", :name => 'submit_export_wiki' %>
    <%= submit_tag "#{t('Export', :scope => :wiki)} HTML", :name => 'submit_export_html' %>
    <%#= submit_tag "#{t('Export')} PDF", :name => 'submit_export_pdf' %>
    <%= submit_tag t('Protected', :scope => :wiki), :name => 'submit_protected' %>
    <%= submit_tag t('Private', :scope => :wiki), :name => 'submit_private' %>
    <%= submit_tag t('Public', :scope => :wiki), :name => 'submit_public' %>
    <%= submit_tag t('Delete', :scope => :wiki), :name => 'submit_delete', 
                   :confirm => t('Are you sure?', :scope => [:wiki, :message]) %>
  <% end -%>
  <table class="tablesorter">
  <thead>
    <th style="width:15px"><input type="checkbox" id="wiki_list_check_box_all"></th>
    <th><%= t('Page Name', :scope => :wiki) %></th>
    <th><%= t('Summary', :scope => :wiki) %></th>
    <th><%= t('Author', :scope => :wiki) %></th>
    <th><%= t('Revision', :scope => :wiki) %></th>
    <th><%= t('Status', :scope => :wiki) %></th>
    <th><%= t('Modify Time', :scope => :wiki) %></th>
  </thead>
  <% @wiki_pages.each do |wiki_page|-%>
  <tr>
    <td><%= check_box_tag "page_id[]", wiki_page.id %></td>
    <td><%= link_to wiki_page.name, project_wiki_path(params[:project_id], wiki_page.name) %></td>
    <td><%= wiki_page.summary %></td>
    <td><%= wiki_page.revised_by %></td>
    <td><%= wiki_page.revision %></td>
    <td><%= t(wiki_page.status_to_s, :scope => :wiki) %></td>
    <td><%= tz_datetime(wiki_page.revised_at) %></td>
  </tr>
  <% end -%>
  </table>
  <%= render :partial => "pager" %>
<% end %>

<hr/>
<%= render :partial => "functions"%>
